package com.xinsilu.hospital.controller;


import com.xinsilu.common.Result;
import com.xinsilu.hospital.entity.ProjectTable;
import com.xinsilu.hospital.service.IProjectTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ym
 * @since 2021-09-22
 */
@RestController
@RequestMapping("/api/hospital/projectTable")
public class ProjectTableController {

    @Autowired
    private IProjectTableService iProjectTableService;

    @RequestMapping("/getlist")
    public Object getList() {
        List<ProjectTable> list = iProjectTableService.list();
        return Result.ok(list);
    }

    @RequestMapping("/xmList")
    public Object xmList(ProjectTable projectTable) {
        List<ProjectTable> list = iProjectTableService.xmlist(projectTable);
        return Result.ok(list);
    }
    @PostMapping("/addxm")
    public  Object addxm(ProjectTable projectTable){
        boolean save = iProjectTableService.save(projectTable);
        if(save){
            return Result.ok("成功");
        }
        return Result.ok(save);
    }
    @RequestMapping("/addProject")
    public Object addProject(ProjectTable projectTable){
        Boolean count = iProjectTableService.save(projectTable);
        if (count) {
            return Result.ok("新增成功");
        }
        return Result.ok("异常");

    }
    @RequestMapping("/updateProject")
    public  Object updateProject(ProjectTable projectTable) {
        Boolean count = iProjectTableService.updateById(projectTable);
        if (count) {
            return Result.ok("新增成功");
        }
        return Result.ok("异常");

    }
}
